home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revolution - Das Atari CD Magazin 1997
/
Revolution - Das Atari CD Magazin 1.iso
/
software
/
anwendng
/
qed_397
/
sourcen
/
projekt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-01-14
|
52KB
|
2,281 lines
#include "global.h"
#include "av.h"
#include "ausgabe.h"
#include "clipbrd.h"
#include "comm.h"
#include "dd.h"
#include "desktop.h"
#include "disk.h"
#include "edit.h"
#include "event.h"
#include "kurzel.h"
#include "file.h"
#include "find.h"
#include "icon.h"
#include "menu.h"
#include "mintlib.h"
#include "obj.h"
#include "printer.h"
#include "rsc.h"
#include "scroll.h"
#include "set.h"
#include "text.h"
#include "trash.h"
#include "windows.h"
#include "projekt.h"
#include "debug.h"
/* exprortierte Variablen **************************************************/
WORD prj_type;
PATH def_prj_path;
/****** DEFINES ************************************************************/
#define KIND (NAME|CLOSER|MOVER|INFO|SIZER|UPARROW|DNARROW|VSLIDE|SMALLER)
#define FLAGS (WI_FONTSIZE|WI_REDRAW)
#define TEMP_PRJ "TEMP$.QPJ"
#define TEMP_LINK 10001
/****** TYPES **************************************************************/
typedef struct { /* für Dreaddir */
LONG inode;
FILENAME name;
} DIRENTRY;
/****** VAR ****************************************************************/
LOCAL SET used_info; /* Icon-Nr für Text und Fenster */
LOCAL WORD do_find_icon, namenlos_anz;
LOCAL PATH df_path;
LOCAL WORD def_icon; /* Icon für Defaultprojekt */
LOCAL RING lastPos;
/****** FUNCTIONS **********************************************************/
LOCAL VOID icon_exist (WORD icon, SET actions);
LOCAL BOOLEAN icon_test (WORD icon, WORD action);
LOCAL WORD icon_edit (WORD icon, WORD action);
LOCAL BOOLEAN icon_drag (WORD icon, WORD source);
LOCAL VOID draw_line (WINDP window, WORD line);
LOCAL VOID wi_draw (WINDP window, CONST RECT *d);
LOCAL VOID wi_click (WINDP window, MKINFO *mk);
LOCAL VOID wi_unclick (WINDP window);
LOCAL BOOLEAN wi_key (WINDP window, MKINFO *mk);
LOCAL VOID wi_snap (WINDP window, RECT *new, WORD mode);
LOCAL VOID wi_iconify (WINDOWP window);
LOCAL VOID wi_uniconify (WINDOWP window);
LOCAL LONG get_direntry (LONG handle, UBYTE *pfad, DIRENTRY *buf, XATTR *attr);
LOCAL BOOLEAN dfind (UBYTE *pfad, UBYTE *df_muster, WORD icon);
LOCAL BOOLEAN dfind_rek (UBYTE *pfad, UBYTE *df_muster, WORD icon);
LOCAL VOID get_prj_line (WORD link, WORD line, UBYTE *str);
LOCAL VOID get_prj_line_file (WORD link, WORD line, UBYTE *str);
LOCAL WORD del_from_projekt (WORD link, WORD line);
LOCAL BOOLEAN open_prj (WORD icon);
LOCAL VOID destruct (WORD icon);
LOCAL VOID crt_prj (WORD icon, WINDP window);
LOCAL BOOLEAN info_projekt (WORD icon);
LOCAL VOID select_def_prj (VOID);
LOCAL BOOLEAN get_lastPos (CONST UBYTE *name, WORD *x, LONG *y);
LOCAL VOID insert_lastPos (CONST UBYTE *name, WORD x, LONG y);
/*****************************************************************************/
LOCAL LONG p_maxvalue;
LOCAL DIALINFO scan_box;
VOID start_prjscan(CONST UBYTE *name, LONG max_value)
{
p_maxvalue = max(max_value,1);
fill_ptext(prjscan, PNAME, name);
fill_ptext(prjscan, PDATEI, "");
prjscan[PBOX2].ob_width = 1;
open_dial(prjscan, TRUE, NULL, &scan_box);
dial_draw(&scan_box);
}
VOID do_prjscan (CONST UBYTE *name, LONG value)
{
LONG max_len, help;
fill_ptext(prjscan,PDATEI,name);
max_len = prjscan[PBOX1].ob_width;
help = max((max_len*value)/p_maxvalue,1);
prjscan[PBOX2].ob_width = (short) min(max_len, help);
draw_Objc(prjscan, PDATEI, 1);
draw_Objc(prjscan, PBOX2, 1);
}
VOID end_prjscan (VOID)
{
dial_end(&scan_box);
}
/*****************************************************************************/
WORD anz_prj_loaded(VOID)
{
return setcard(used_info);
}
WORD prj_still_loaded(CONST UBYTE *name)
{
WORD i, min;
min = setmin(used_info);
for (i=setmax(used_info); i>=min; i--)
if (setin(used_info,i))
{
TEXTP t_ptr = get_text(i);
/* if (!t_ptr->namenlos && filematch(t_ptr->filename, name))*/
if (!t_ptr->namenlos && strcmp(t_ptr->filename, name)==0)
return i;
}
return -1;
}
LOCAL VOID do_for_prj(WORD icon, SET s, WORD (*do_it)(WORD,WORD), BOOLEAN verbose)
{
TEXTP t_ptr, t_ptr2;
LINEP lauf;
WORD min, i, anz, soll, erg;
PATH name;
FILENAME file;
t_ptr = get_text(icon);
if (verbose)
{
t_ptr2 = get_text(icon);
if (t_ptr2->namenlos)
strcpy(file, t_ptr2->filename);
else
file_name(t_ptr2->filename,file, FALSE);
start_prjscan(file,setcard(s));
}
min = setmin(s);
/* So wg. DO_CLEAR */
for (i=setmax(s); i>=min; i--)
{
if (setin(s,i))
{
lauf = get_line(&t_ptr->text,i);
lauf->info |= 128;
}
}
soll = setcard(s);
anz = i = 0;
while (TRUE)
{
if (abbruch())
{
if (anz<soll && note(2,BREAK)==1) break;
}
lauf = get_line(&t_ptr->text,i);
if (lauf==NULL) break;
if (lauf->info&128)
{
anz++;
lauf->info &= (~128); /* sonst Endlosschleife */
if (verbose)
{
get_prj_line_file(icon,i,name);
if (name[0]==EOS) break;
file_name(name,file, FALSE);
do_prjscan(file,anz);
}
erg = (*do_it)(icon,i);
if (erg<0) break;
if (erg==0)
{
if (anz<soll && note(2,BREAK)==1) break;
}
}
else
i++;
}
lauf = FIRST(&t_ptr->text);
while (!IS_TAIL(lauf))
{
lauf->info &= (~128);
NEXT(lauf);
}
if (verbose) end_prjscan();
}
LOCAL VOID do_for_prj2(WORD icon, SET s, BOOLEAN (*do_it)(WORD))
{
WORD i, t_icon, anz, soll;
TEXTP t_ptr, t_ptr2;
PATH name;
FILENAME file;
t_ptr = new_text(TEMP_LINK);
if (t_ptr==NULL) return;
t_ptr2 = get_text(icon);
if (t_ptr2->namenlos)
strcpy(file, t_ptr2->filename);
else
file_name(t_ptr2->filename,file, FALSE);
start_prjscan(file,setcard(s));
soll = setcard(s);
for (i=setmin(s),anz=0; anz<soll; i++)
{
if (setin(s,i))
{
anz++;
get_prj_line_file(icon,i,name);
if (name[0]==EOS) break;
file_name(name,file, FALSE);
do_prjscan(file,anz);
if ((t_icon=still_loaded(name))>=0)
{
if (!(*do_it)(t_icon)) break;
}
else
{
set_text_name(t_ptr, name, FALSE);
if (load(t_ptr, FALSE)<0)
if (anz<soll && note(2,BREAK)==1) break;
if (!(*do_it)(TEMP_LINK)) break;
clear_text(t_ptr);
}
}
if (abbruch())
{
if (anz<soll && note(2,BREAK)==1) break;
}
}
destruct_text(t_ptr);
end_prjscan();
}
LOCAL BOOLEAN delete_prj(WORD icon)
{
TEXTP t_ptr = get_text(icon);
WORD antw;
FILENAME name;
/* if (!ist_leer(&t_ptr->text) && t_ptr->moved!=0)
Ungeschickt: wenn man mit ^X alles gelöscht hat, wird nicht nachgefragt
bzw. gesichert, sondern die Datei so gelassen, wie sie war! */
if (t_ptr->moved!=0)
{
if (quick_close)
antw = 1;
else
{
if (t_ptr->namenlos)
strcpy(name, t_ptr->filename);
else
file_name(t_ptr->filename, name, FALSE);
antw = snote(1, MOVED, name);
}
if (antw==1)
{
if (do_icon(icon,DO_SAVE)<0)
return (FALSE);
}
if (antw==3) return(FALSE);
}
return (TRUE);
}
LOCAL VOID chg_prj_name(WORD icon)
{
WINDP window;
FILENAME name;
TEXTP t_ptr = get_text(icon);
file_name(t_ptr->filename, name, TRUE);
window = get_window (icon);
set_icon_name(icon,name);
set_wname(window,name);
}
/***************************************************************************/
/* Operation vorhanden ? */
/***************************************************************************/
LOCAL VOID icon_exist(WORD icon, SET actions)
{
setclr(actions);
if (icon & SUB_ICON)
{
setincl(actions,DO_CLEAR);
setincl(actions,DO_OPEN);
setincl(actions,DO_INFO);
setincl(actions,DO_FIND);
setincl(actions,DO_HELP);
}
else
{
WINDP window = get_window(icon);
TEXTP t_ptr = get_text(icon);
if (window->flags & WI_ICONIFIED)
{
setincl(actions,DO_DESTRUCT);
}
else
{
if (window->opened)
setincl(actions, DO_CLOSE);
setincl(actions, DO_CLEAR);
setincl(actions, DO_SELALL);
setincl(actions, DO_DESTRUCT);
setincl(actions, DO_OPEN);
setincl(actions, DO_INFO);
setincl(actions, DO_FIND);
if (!t_ptr->namenlos)
setincl(actions, DO_ABAND);
setincl(actions, DO_SAVE);
setincl(actions, DO_SAVENEW);
setincl(actions, DO_GOTO);
setincl(actions, DO_UPDATE);
setincl(actions, DO_PRINT);
setincl(actions, DO_HELP);
setincl(actions, DO_ADD);
setincl(actions, DO_AUTOSAVE);
}
}
}
/***************************************************************************/
/* Operation testen */
/***************************************************************************/
LOCAL BOOLEAN icon_test(WORD icon, WORD action)
{
BOOLEAN erg;
if (icon & SUB_ICON)
{
switch(action)
{
case DO_CLEAR : erg = TRUE; break;
case DO_OPEN : erg = TRUE; break;
case DO_INFO : erg = TRUE; break;
case DO_FIND : erg = find_dial(TRUE); break;
case DO_HELP : erg = TRUE; break;
default : erg = FALSE;
}
}
else
{
FILENAME name;
TEXTP t_ptr = get_text(icon);
WINDP window = get_window(icon);
switch(action)
{
case DO_CLEAR : erg = delete_prj(icon); break;
case DO_SELALL : erg = TRUE; break;
case DO_CLOSE : erg = window->opened; break;
case DO_DESTRUCT: erg = delete_prj(icon); break;
case DO_OPEN : erg = TRUE; break;
case DO_INFO : erg = TRUE; break;
case DO_FIND : erg = find_dial(TRUE); break;
case DO_ABAND : if (t_ptr->namenlos)
erg = FALSE;
else
{
erg = TRUE;
if (!ist_leer(&t_ptr->text) && t_ptr->moved!=0)
{
file_name(t_ptr->filename, name, FALSE);
erg = (snote(1,ABANDON,name)==1);
}
}
break;
case DO_SAVE :
erg = TRUE; break;
case DO_SAVENEW:
erg = TRUE; break;
case DO_GOTO :
erg = goto_line_dial(); break;
case DO_UPDATE :
erg = TRUE; break;
case DO_PRINT :
erg = TRUE; break;
case DO_HELP :
erg = TRUE; break;
case DO_ADD :
erg = diskfind_dial(df_path, df_name);
break;
case DO_AUTOSAVE :
if (as_proj && t_ptr->moved)
{
WORD min, btn;
min = local_time->tm_min - t_ptr->count;
if (min >= as_proj_min)
{
if (as_proj_ask) /* Nachfrage ? */
{
FILENAME name;
if (t_ptr->namenlos)
strcpy(name, t_ptr->filename);
else
file_name(t_ptr->filename, name, FALSE);
mybeep();
btn = snote(2, ASAVEASK, name);
if (btn == 1)
as_proj = FALSE;
}
else
btn = 2;
t_ptr->count = local_time->tm_min;
erg = (btn == 2);
}
else
erg = FALSE;
}
else
{
t_ptr->count = local_time->tm_min;
erg = FALSE;
}
break;
default :
erg = FALSE;
}
}
return erg;
}
/***************************************************************************/
/* Operation durchführen */
/***************************************************************************/
LOCAL WORD do_open(WORD prj_icon, WORD i)
{
PATH name;
WORD icon;
BOOLEAN prj;
get_prj_line_file(prj_icon, i, name);
prj = filematch(name, "*.QPJ");
if (prj)
{
if ((icon = prj_still_loaded(name))>=0)
{
if (do_icon(icon, DO_OPEN)<0) /* Nur Fenster öffnen */
{
note(1, NOWINDOW);
return -1; /* keine weiteren Versuche */
}
return 1; /* OK */
}
else
if (global_shift)
return load_edit(name, TRUE, -1, -1, NULL);/* Laden als Text und öffnen */
else
return load_projekt(name, TRUE, -1, -1, NULL);/* Laden als Projekt und öffnen */
}
else
{
if ((icon = still_loaded(name))>=0)
{
if (do_icon(icon, DO_OPEN)<0) /* Nur Fenster öffnen */
{
note(1, NOWINDOW);
return -1; /* keine weiteren Versuche */
}
return 1; /* OK */
}
else
{
WORD x;
LONG y;
icon = load_edit(name, TRUE, -1, -1, NULL); /* Laden als Text und öffnen */
if (get_lastPos(name, &x, &y))
{
desire_x = x;
desire_y = y;
Icon_edit(icon, DO_GOTO);
}
else
insert_lastPos(name, 0, 0);
return icon;
}
}
}
LOCAL BOOLEAN do_find(WORD icon)
{
WORD erg;
TEXTP t_ptr = get_text(icon);
erg = start_find(t_ptr,TRUE);
if (erg==1)
add_to_projekt(do_find_icon, t_ptr->filename, FALSE);
return (erg!=-1);
}
LOCAL WORD icon_edit(WORD icon, WORD action)
{
PATH name;
WORD erg;
erg = 0;
if (icon&SUB_ICON)
{
WINDP window;
TEXTP t_ptr;
SET help;
icon &= (~SUB_ICON);
window = get_window(icon);
if (sel_window==window)
setcpy(help,sel_objs);
else
setclr(help);
switch (action)
{
case DO_CLEAR :
do_for_prj(icon,help,del_from_projekt,FALSE);
break;
case DO_OPEN :
do_for_prj(icon,help,do_open,FALSE);
break;
case DO_INFO :
do_for_prj2(icon,help,info_edit);
break;
case DO_FIND :
do_find_icon = crt_new_prj("",-1,-1,NULL);
if (do_find_icon<0)
break;
if (do_icon(do_find_icon,DO_OPEN)<0)
{
note(1, NOWINDOW);
if (no_desktop)
{
Icon_edit(icon, DO_DESTRUCT);
break;
}
}
do_for_prj2(icon,help,do_find);
t_ptr = get_text(do_find_icon);
if (t_ptr->moved) /* etwas gefunden? */
{
t_ptr->moved = 0;
window = get_window(do_find_icon);
change_window(window, FALSE);
set_sliders(window, VERTICAL, SLPOS+SLSIZE);
redraw_window(window,&window->work);
}
else
Icon_edit(do_find_icon, DO_DESTRUCT); /* wenn nicht, gleich wieder zu */
break;
case DO_HELP :
erg = call_hyp(STRING(HYPPRJSTR));
break;
}
erg = 1;
}
else
{
TEXTP t_ptr = get_text(icon);
WINDP window = get_window(icon);
WORD i;
SET help;
FILENAME file;
PATH h;
FSEL fsel;
switch(action)
{
case DO_DESTRUCT:
case DO_CLEAR :
if (icon == def_icon)
{
def_icon = -1;
set_def_prj();
}
destruct(icon);
erg = 1;
break;
case DO_SELALL :
if (window != sel_window)
unclick_window();
if (!ist_leer(&t_ptr->text))
{
sel_window = window;
for (i = (short) t_ptr->text.lines; (--i)>=0; )
setincl(sel_objs,i);
redraw_window(window,&window->work);
}
erg = 1;
break;
case DO_CLOSE :
close_window(window);
if (icon == def_icon)
{
def_icon = -1;
set_def_prj();
}
erg = 1;
break;
case DO_OPEN :
if (!open_prj (icon))
erg = -1;
else
erg = 1;
break;
case DO_INFO :
info_projekt(icon);
erg = 1;
break;
case DO_FIND :
setclr(help);
for (i = (short) t_ptr->text.lines; (--i)>=0; )
setincl(help,i);
do_find_icon = crt_new_prj("",-1,-1,NULL);
if (do_find_icon<0)
break;
if (do_icon(do_find_icon,DO_OPEN)<0)
{
note(1, NOWINDOW);
if (no_desktop)
{
Icon_edit(icon, DO_DESTRUCT);
break;
}
}
do_for_prj2(icon,help,do_find);
t_ptr = get_text(do_find_icon);
if (t_ptr->moved) /* etwas gefunden? */
{
t_ptr->moved = 0;
window = get_window(do_find_icon);
change_window(window, FALSE);
set_sliders(window, VERTICAL, SLPOS+SLSIZE);
redraw_window(window,&window->work);
}
else
Icon_edit(do_find_icon, DO_DESTRUCT); /* wenn nicht, gleich wieder zu */
erg = 1;
break;
case DO_ABAND :
strcpy(name, t_ptr->filename);
desire_y = window->doc.y+1;
window->init = 1; /* das will ich wieder haben */
destruct_window(window);
destruct_text(t_ptr);
del_icon_from_desk(icon);
del_icon(icon);
setexcl(used_info,icon);
icon = load_projekt(name,TRUE,-1,-1,NULL);
if (icon > 0)
{
t_ptr = get_text(icon);
if (t_ptr!=NULL)
{
i = (short) (desire_y - window->doc.y);
arrow_window(window,WA_DNLINE,i);
restore_edit();
open_prj(icon);
memset(msgbuff, 0, (WORD) sizeof(msgbuff));
msgbuff[0] = WM_TOPPED;
msgbuff[3] = window->handle;
send_msg(gl_apid);
erg = 1;
}
}
break;
case DO_SAVE :
if (!t_ptr->namenlos)
{
if (save(t_ptr) < 0)
erg = -1;
else
{
change_window(window, FALSE);
erg = 1;
}
break;
}
/* Bei Namenlos zu DO_SAVENEW */
case DO_SAVENEW:
strcpy(fsel.name,"");
strcpy(fsel.suffix,"*.QPJ");
if (save_new(name,&fsel,STRING(SAVEPRJSTR)))
{
make_ext(name,"qpj");
if ((erg=save_as(t_ptr,name))==0)
{
if (t_ptr->namenlos || note(1,GETNAME)==1)
{
set_text_name(t_ptr, name, FALSE);
chg_prj_name(icon);
t_ptr->moved = 0;
t_ptr->file_date_time = file_time(name,NULL,NULL);
t_ptr->readonly = file_readonly(name);
}
change_window(window, FALSE);
erg = 1;
}
}
break;
case DO_GOTO :
i = (short) (desire_y - window->doc.y);
arrow_window(window,WA_DNLINE,i);
erg = 1;
break;
case DO_UPDATE :
redraw_window(window, &window->work);
erg = 1;
break;
case DO_PRINT :
if (t_ptr->namenlos)
strcpy(file, t_ptr->filename);
else
file_name(t_ptr->filename, file, FALSE);
if (prn_options(file, FALSE))
txt_drucken(file,t_ptr);
erg = 1;
break;
case DO_HELP :
erg = call_hyp(STRING(HYPPRJSTR));
break;
case DO_ADD :
if (df_path[0]!=EOS) /* Pfad durchsuchen */
{
Busy_mouse();
strcpy(h, df_path);
if (!caseSens(df_path, NULL))
str_upper(df_name);
if (df_rekursiv)
dfind_rek(h, df_name, icon);
else
dfind(h, df_name, icon);
Last_mouse();
redraw_window(window, &window->work);
}
break;
case DO_AUTOSAVE:
icon_edit(icon, DO_SAVE);
break;
}
}
return erg;
}
/***************************************************************************/
/* Ein Icon wurde auf ein Projekt-Icon geschoben */
/***************************************************************************/
LOCAL BOOLEAN icon_drag (WORD icon, WORD source)
{
TEXTP t_ptr;
WINDP window;
BOOLEAN erg = FALSE;
PATH h;
switch (source)
{
case DRAGDROP_FILE :
if (drag_filename[0] != EOS)
{
erg = add_to_projekt(icon, drag_filename, TRUE);
drag_filename[0] = EOS;
}
break;
case DRAGDROP_PATH :
if (drag_filename[0] != EOS)
{
window = get_window(icon);
strcpy(df_path, drag_filename);
erg = diskfind_dial(df_path, df_name);
if (erg)
{
Busy_mouse();
strcpy(h, df_path);
if (!caseSens(df_path, NULL))
str_upper(df_name);
if (df_rekursiv)
dfind_rek(h, df_name, icon);
else
dfind(h, df_name, icon);
Last_mouse();
redraw_window(window, &window->work);
}
drag_filename[0] = EOS;
}
break;
case DRAGDROP_DATA :
mybeep();
erg = FALSE;
break;
default:
t_ptr = get_text(source);
window = get_window(source);
if (t_ptr!=NULL && !t_ptr->namenlos && window!=NULL &&
(window->class==CLASS_EDIT || window->class==CLASS_PROJEKT))
{
erg = add_to_projekt(icon, t_ptr->filename, TRUE);
}
}
return erg;
}
/***************************************************************************/
/*
* Dateien für Projekt suchen.
*
* Unter MiNT wird mit Dopendir/Dreaddir gesucht, da Fsfirst/Fsnext
* auf MinixFS nichts finden!
*
*/
LONG get_direntry(LONG handle, UBYTE *pfad, DIRENTRY *buf, XATTR *attr)
{
LONG r;
PATH tmp;
r = Dreaddir((WORD) sizeof(DIRENTRY), handle, (UBYTE *)buf); /* Eintrag holen */
if (r < 0)
return r;
strcpy(tmp, pfad);
strcat(tmp, buf->name);
r = Fxattr(0, tmp, attr); /* Attribute holen */
if (r < 0)
return r;
return 0;
}
LOCAL BOOLEAN dfind(UBYTE *pfad, UBYTE *df_muster, WORD icon)
/* Sammelt alle Dateien in einem Pfad auf */
{
TEXTP t_ptr;
UBYTE *ptr;
BOOLEAN raus;
WORD t_icon;
PATH suchPfad;
LONG dh;
if (s_str[0]!=EOS)
{
t_ptr = new_text(TEMP_LINK);
if (t_ptr==NULL) return TRUE;
}
strcpy(suchPfad, pfad);
ptr = pfad + strlen(pfad);
dh = Dopendir(suchPfad, 0);
if (dh != -32)
{
DIRENTRY entry;
XATTR attr;
LONG fehler;
do_find_icon = icon;
if (dh < 0)
return FALSE;
raus = FALSE;
fehler = get_direntry(dh, suchPfad, &entry, &attr);
while (fehler == 0 && !raus)
{
if ((attr.attr != 16) && filematch(entry.name, df_muster))
{
strcpy(ptr, entry.name);
if (s_str[0] !=EOS)
{
if ((t_icon=still_loaded(pfad)) <0)
{
set_text_name(t_ptr, pfad, FALSE);
if (load(t_ptr,FALSE) < 0)
if (note(2,BREAK)==1)
break;
if (!do_find(TEMP_LINK))
raus = TRUE;
clear_text(t_ptr);
}
else
{
if (!do_find(t_icon))
raus = TRUE;
}
}
else
add_to_projekt(icon, pfad, TRUE);
}
fehler = get_direntry(dh, suchPfad, &entry, &attr);
if (abbruch() && note(2, BREAK) == 1)
raus = TRUE;
} /* while */
if (fehler != -33 && fehler != -49)
raus = TRUE;
Dclosedir(dh);
if (s_str[0] != EOS)
destruct_text(t_ptr);
return raus;
}
else /* es gibt kein Dopendir! */
{
DTA dta,*olddta;
WORD fehler;
str_upper(df_muster); /* Maske nach Großbuchstaben! */
olddta = Fgetdta ();
Fsetdta(&dta);
strcpy(ptr,"*.*");
raus = FALSE;
fehler = Fsfirst(pfad,0x0); /* Dateien */
do_find_icon = icon;
while (fehler==0 && !raus)
{
if (!(dta.d_attrib&0x1E) && filematch(dta.d_fname, df_muster))
{
strcpy(ptr,dta.d_fname);
if (s_str[0]!=EOS) /* Datei nach String absuchen */
{
if ((t_icon=still_loaded(pfad))<0)
{
set_text_name(t_ptr, pfad, FALSE);
if (load(t_ptr,FALSE)<0)
if (note(2,BREAK)==1)
break;
if (!do_find(TEMP_LINK))
raus = TRUE;
clear_text(t_ptr);
}
else
{
if (!do_find(t_icon))
raus = TRUE;
}
}
else
add_to_projekt(icon,pfad,TRUE);
}
fehler = Fsnext();
if (abbruch() && note(2,BREAK)==1)
raus = TRUE;
}
if (fehler!=-33 && fehler!=-49)
raus = TRUE;
Fsetdta(olddta);
if (s_str[0]!=EOS)
destruct_text(t_ptr);
return raus;
}
}
LOCAL BOOLEAN dfind_rek(UBYTE *pfad, UBYTE *df_muster,WORD icon)
/* Sammelt alle Dateien in einem Pfad REKURSIV auf */
{
UBYTE *ptr;
BOOLEAN raus;
PATH suchPfad;
LONG dh;
ptr = pfad + strlen(pfad);
strcpy(suchPfad, pfad);
dh = Dopendir(pfad, 0);
if (dh != -32)
{
DIRENTRY entry;
XATTR attr;
LONG fehler;
if (dh < 0)
return FALSE;
fehler = get_direntry(dh, suchPfad, &entry, &attr);
raus = FALSE;
while (fehler == 0 && !raus)
{
if ((attr.attr == 16) && strcmp(entry.name, ".") && strcmp(entry.name, ".."))
{
strcpy(ptr, entry.name);
strcat(ptr, "\\");
raus = dfind_rek(pfad, df_muster, icon);
}
fehler = get_direntry(dh, suchPfad, &entry, &attr);
if (abbruch() && note(2, BREAK) == 1)
raus = TRUE;
} /* while */
Dclosedir(dh);
ptr[0] = EOS;
if (fehler != -33 && fehler != -49)
raus = TRUE;
if (!raus)
raus = dfind(pfad, df_muster, icon);
return raus;
}
else
{
DTA dta,*olddta;
WORD fehler;
olddta = Fgetdta ();
Fsetdta(&dta);
strcat(pfad,"*.*");
fehler = Fsfirst(pfad,0x10); /* Directory-Einräge */
raus = FALSE;
while (fehler==0 && !raus)
{
if (dta.d_attrib==0x10 && strcmp(dta.d_fname,".") && strcmp(dta.d_fname,".."))
{
strcpy(ptr,dta.d_fname);
strcat(ptr,"\\");
raus = dfind_rek(pfad,df_muster,icon);
}
fehler = Fsnext();
if (abbruch() && note(2,BREAK)==1)
raus = TRUE;
}
ptr[0] = EOS;
if (fehler!=-33 && fehler!=-49)
raus = TRUE;
if (!raus)
raus = dfind(pfad, df_muster,icon);
Fsetdta(olddta);
return raus;
}
}
/***************************************************************************/
LOCAL VOID get_prj_line(WORD link, WORD line, UBYTE *str)
{
TEXTP t_ptr = get_text(link);
LINEP lauf;
lauf = get_line(&t_ptr->text,line);
if (lauf!=NULL)
{
strcpy(str,TEXT(lauf));
}
else
str[0] = EOS;
}
/***************************************************************************/
LOCAL VOID get_prj_line_file(WORD link, WORD line, UBYTE *str)
{
UBYTE s[256], *ptr;
get_prj_line(link,line,s);
ptr = s;
while (*ptr!=' ' && *ptr!=EOS) ptr++;
*ptr = EOS;
strcpy(str,s);
}
/***************************************************************************/
LOCAL WORD del_from_projekt (WORD link, WORD line)
{
TEXTP t_ptr = get_text(link);
LINEP lauf;
lauf = get_line(&t_ptr->text,line);
if (lauf!=NULL)
{
WINDP window = get_window(link);
unclick_window();
if (t_ptr->text.lines>1)
{
col_delete(lauf);
t_ptr->text.lines--;
window->doc.h--;
set_sliders(window, VERTICAL, SLPOS+SLSIZE);
redraw_window(window,&window->work);
}
else
{
REALLOC(&lauf,0,-lauf->len);
redraw_window(window,&window->work);
}
t_ptr->moved++;
change_window(window, TRUE); /* '*' in den Titel */
}
return 1;
}
BOOLEAN add_to_projekt (WORD link, UBYTE *name, BOOLEAN draw)
{
WORD erg, i;
TEXTP t_ptr = get_text(link);
PATH file;
if (!caseSens(name, NULL))
str_upper(name);
strcpy(file,name);
if (!make_normalpath(file,TRUE)) return FALSE;
erg = 1; i = 0;
get_prj_line_file(link,i,file);
while (file[0] != EOS && (erg = strcmp(file, name)) < 0)
{
i++;
get_prj_line_file(link,i,file);
}
if (erg) /* noch nicht vorhanden */
{
WINDP window = get_window(link);
if (ist_leer(&t_ptr->text))
INSERT(&FIRST(&t_ptr->text),0,(short)strlen(name),name);
else
{
LINEP new, lauf;
if (i==0)
lauf = &t_ptr->text.head;
else
lauf= get_line(&t_ptr->text,i-1);
new = new_col_b(name,(short)strlen(name));
col_insert(lauf,new);
t_ptr->text.lines++;
window->doc.h++;
if (draw)
set_sliders(window, VERTICAL, SLPOS+SLSIZE);
}
if (draw)
redraw_window(window,&window->work);
t_ptr->moved++;
change_window(window, TRUE); /* '*' in den Titel */
return TRUE;
}
return FALSE;
}
LOCAL VOID clear_loaded(TEXTP t_ptr)
{
LINEP lauf;
UBYTE name[256], param[256];
UBYTE *str;
lauf = FIRST(&t_ptr->text);
while (!IS_TAIL(lauf))
{
str = TEXT(lauf);
while (*str==' ' || *str=='\t') str++;
strcpy(name,str);
str = name;
while (*str!=' ' && *str!='\t' && *str!=EOS) str++;
while (*str==' ' || *str=='\t') str++;
strcpy(param,str);
if (make_normalpath(name,TRUE))
{
WORD l;
l = (short)strlen(name);
str = REALLOC(&lauf, 0, l + 1 + (short)strlen(param) - lauf->len);
str = COPYB(str,name,l);
*str++ = ' ';
strcpy(str,param);
NEXT(lauf);
}
else
{
if (t_ptr->text.lines>1)
{
LINEP help;
help = lauf->nachf;
col_delete(lauf);
t_ptr->text.lines--;
lauf = help;
}
else
{
REALLOC(&lauf,0,-lauf->len);
NEXT(lauf);
}
}
}
}
WORD load_projekt(CONST UBYTE *name, BOOLEAN open, WORD icon_x, WORD icon_y, RECT *win)
/* return: <=0 wurde nicht geladen */
/* 0 weitere Texte versuchen sinnvoll */
/* <0 weiter Texte versuchen nicht sinnvoll */
{
WORD err, icon;
WINDP window;
FILENAME datei;
PATH path;
TEXTP t_ptr;
set_fsel_path(name);
file_splitt(name, path, datei);
if ((icon=prj_still_loaded(name))>=0) /* schon geladen */
{
if (do_icon(icon,DO_OPEN) < 0) /* nur Fenster auf */
note(1, NOWINDOW);
if (filematch(name, def_prj_path)) /* Default-Prj wurde geöffnet */
{
def_icon = icon;
set_def_prj();
}
return icon;
}
icon = crt_new_prj(name, icon_x, icon_y, win);
if (icon<0)
{
note(1,NOTEXT);
return -1;
}
t_ptr = get_text(icon);;
if ((err=load(t_ptr, TRUE))==-33) /* File not Found */
{
if (path_exist(path))
{
if (snote(1,NEWTEXT,datei)==2)
{
Icon_edit(icon,DO_DESTRUCT);
return 0;
}
}
else
{
snote(1, READERR, datei);
Icon_edit(icon,DO_DESTRUCT);
return 0;
}
}
else if (err) /* anderer Fehler */
{
snote(1, READERR, datei);
Icon_edit(icon,DO_DESTRUCT);
return 0;
}
clear_loaded(t_ptr);
window = get_window(icon);
window->doc.y = 0;
window->doc.h = t_ptr->text.lines;
if ((open && !(nkc_kstate() & 3L)) || no_desktop)
{
if (do_icon(icon,DO_OPEN)<0 && no_desktop)
{
note(1, NOWINDOW);
Icon_edit(icon,DO_DESTRUCT);
icon = -2;
}
}
if (filematch(name, def_prj_path)) /* Default-Prj wurde geladen */
{
def_icon = icon;
set_def_prj();
}
return icon;
}
LOCAL VOID destruct(WORD icon)
{
TEXTP t_ptr = get_text(icon);
WINDP window = get_window(icon);
destruct_window(window);
del_icon_from_desk(icon);
destruct_text(t_ptr);
del_icon(icon);
setexcl(used_info,icon);
do_all_icon(prj_type,DO_UPDATE); /* Projekte updaten */
}
/***************************************************************************/
/* Anlegen eines neuen Projekts */
/***************************************************************************/
WORD new_prj(VOID)
{
WORD icon;
icon = crt_new_prj("",-1,-1,NULL);
if (icon<0)
{
note(1,NOTEXT);
return -1;
}
if (!(nkc_kstate() & 3) || no_desktop)
{
if (do_icon(icon,DO_OPEN)<0)
{
note(1, NOWINDOW);
if (no_desktop)
{
Icon_edit(icon, DO_DESTRUCT);
icon = -3;
}
}
}
return icon;
}
/* new_prj */
WORD crt_new_prj (CONST UBYTE *filename, WORD icon_x, WORD icon_y, RECT *win)
{
WORD icon;
BOOLEAN namenlos;
TEXTP t_ptr;
WINDP window;
FILENAME datei;
PATH name;
strcpy(name,filename);
if (name[0]==EOS)
{
UBYTE str[20], *ptr;
WORD len;
strcpy(name, STRING(NAMENLOS));
itoa(++namenlos_anz,str,10);
len = (short)strlen(str);
ptr = strchr(name,'$');
if (ptr!=NULL)
{
MOVE(ptr+len,ptr+1,(short)strlen(ptr));
COPYB(ptr,str,len);
}
strcpy(datei, name);
namenlos = TRUE;
}
else
{
file_name(name,datei, FALSE);
namenlos = FALSE;
}
icon = add_icon_to_desk(IPROJEKT, datei, icon_x, icon_y);/* Neues Icon instalieren */
if (icon < 0)
return -1;
if (!add_icon(prj_type,icon))
{
del_icon_from_desk(icon);
return -1;
}
t_ptr = new_text(icon); /* Neuen Text anlegen */
if (t_ptr==NULL)
{
del_icon(icon);
del_icon_from_desk(icon);
return -1;
}
set_text_name(t_ptr, name, namenlos);
setincl(used_info,icon);
if ((window=create_window(KIND, CLASS_PROJEKT, icon, crt_prj))==NULL)
{
setexcl(used_info,icon);
destruct_text(t_ptr);
del_icon(icon);
del_icon_from_desk(icon);
return -1;
}
if (win!=NULL && win->w>0)
{
size_window(window,win,FALSE);
}
if (!namenlos)
{
do_all_icon(prj_type,DO_UPDATE); /* Projekte updaten */
}
t_ptr->count = local_time->tm_min;
return(icon);
}
/***************************************************************************/
LOCAL VOID draw_line (WINDP window, WORD line)
{
TEXTP t_ptr;
RECT r;
t_ptr = get_text(window->link);
if (line>=t_ptr->text.lines) return;
line -= (short)window->doc.y;
if (line<0) return;
if (line>=window->w_hight) return;
r.x = window->work.x;
r.y = window->work.y+line*gl_hchar;
r.w = window->work.w;
r.h = gl_hchar;
redraw_window(window,&r);
}
LOCAL VOID wi_draw (WINDP window, CONST RECT *d)
{
LINEP lauf;
TEXTP t_ptr;
WORD line, y, x, i, link;
PATH name, str;
set_clip(TRUE,d);
line = (short)window->doc.y;
y = window->work.y;
x = window->work.x;
i = window->w_hight;
if (d->y > y)
{
WORD anz;
anz = (d->y-y)/gl_hchar;
line += anz;
y += anz*gl_hchar;
i -= anz;
}
if (d->y+d->h < window->work.y+window->work.h)
{
WORD anz;
anz = ((window->work.y+window->work.h)-(d->y+d->h))/gl_hchar;
i -= anz;
}
link = window->link;
t_ptr = get_text(link);
lauf = get_line(&t_ptr->text,line);
if (lauf!=NULL)
{
while ((--i)>=0)
{
get_prj_line_file(link,line,str);
if (str[0]==EOS)
{
i++;
break;
}
if ((still_loaded(str) >= 0) || (prj_still_loaded(str) >= 0))
name[0] = '*';
else
name[0] = ' ';
make_shortpath(str,name+1,window->w_width-1);
if (window==sel_window && setin(sel_objs,line))
outsB(x,y,window->work.w,name);
else
outs(x,y,window->work.w,name);
line++;
y += gl_hchar;
}
}
for (; (--i)>=0; y+=gl_hchar)
outc(x,y,window->work.w);
}
/***************************************************************************/
/*
* Neue Drag-Funktion!!
* Funkt bisher nur für Projekte, aber dafür auch unter N.AES.
* Projekt-Elemente können keine qed-Desktop-Funktionen mehr auslösen,
* da der beim nächsten Version sowieso 'rausfliegt!!
*
* Return: Fenster-ID
*/
LOCAL WORD drag_objs(WORD w, WORD h, WORD x, WORD y, MKINFO *mk)
{
WORD wh, d;
Set_mouse (FLAT_HAND);
graf_dragbox(w, h, x, y, desk.x, desk.y, desk.w, desk.h, &d, &d);
Last_mouse ();
graf_mkstate(&mk->mox, &mk->moy, &d, &mk->kstate);
wh = wind_find(mk->mox, mk->moy);
return wh;
}
LOCAL VOID wi_click (WINDP window, MKINFO *mk)
{
WORD y, result, mobutton;
RECT *s = &window->work;
PATH str;
SET new_obj;
if (mk->mobutton & 2) /* Rechtsklick */
return;
if (!inside(mk->mox,mk->moy,s))
return;
if (sel_window!=window)
unclick_window();
set_winfo(window,"");
y = (short)(window->doc.y) + (mk->moy - s->y) / gl_hchar;
get_prj_line_file(window->link, y, str);
if (str[0] == EOS)
return;
setclr (new_obj);
setincl (new_obj, y); /* Aktuelles Objekt */
if (mk->kstate & (K_RSHIFT|K_LSHIFT))
{
setxor (sel_objs, new_obj);
if (setcmp(sel_objs, NULL))
sel_window = NULL;
else
sel_window = window;
draw_line (window, y);
if (!setin (sel_objs, y))
{
graf_mkstate (&result, &result, &mobutton, &result);
if (mobutton&1) /* Immernoch gedrückt ? */
evnt_button(1, 1, 0, &result, &result, &result, &result);
return;
}
}
else /* noch nicht angeklickt */
{
graf_mkstate (&result, &result, &mobutton, &result);
if (!(mobutton & 1)) /* Immernoch gedrückt -> nichts tun */
{
BOOLEAN re_sel;
re_sel = setcmp(new_obj, sel_objs);
unclick_window (); /* Alle Objekte löschen */
/* re_sel ist TRUE, wenn ein Eintrag zum zweiten Mal selektiert wurde
* -> wieder deselektieren.
*/
if (!re_sel)
{
setincl(sel_objs, y);
sel_window = window;
}
draw_line(window, y);
}
}
if (mk->breturn == 1 && mk->mobutton & 1) /* Zieh-Operation */
{
RECT first;
WORD num_objs, i, obj;
WINDP qed_win;
graf_mkstate (&result, &result, &mobutton, &result);
if (!(mobutton&1))
return; /* Immernoch gedrückt ? */
if (window==sel_window)
setcpy(new_obj,sel_objs);
num_objs = 0;
for (i = 0; i < window->w_hight; i++)
{
if (setin(new_obj, i + (short)window->doc.y))
{
if (num_objs == 0) /* Abmessungen des ersten merken */
{
first.x = s->x;
first.y = s->y + (i * gl_hchar);
first.w = s->w;
}
num_objs++;
}
}
obj = drag_objs(first.w, gl_hchar * num_objs, first.x, first.y, mk);
qed_win = find_window(obj);
if (qed_win) /* eigenes Fenster */
{
if (qed_win != window && (qed_win->class == CLASS_PROJEKT ||
qed_win->class == CLASS_EDIT))
{
drag_data_size = num_objs;
for (i = 0; i < window->w_hight; i++)
if (setin(new_obj, i + (short)window->doc.y))
{
get_prj_line_file(window->link, i + (short)window->doc.y, drag_filename);
if (drag_filename[0] == EOS)
break;
if ((mk->kstate & K_ALT) || (qed_win->class == CLASS_PROJEKT))
Icon_drag(qed_win->link, DRAGDROP_FILE);
if (mk->kstate & (K_LSHIFT|K_RSHIFT))
Icon_drag(qed_win->link, DRAGDROP_PATH);
}
drag_data_size = 0;
}
}
else /* fremdes Fenster */
{
/*
* Bisher wird immer an den Desktop geschickt,
* aber nur, wenn dieser AV_DRAG_ON_WINDOW kann.
*/
if ((av_shell_id >= 0) && (av_shell_status & 512))
{
if (num_objs > 1)
{
drag_data_size = (LONG)num_objs * sizeof(PATH);
drag_data = (UBYTE *)Malloc(drag_data_size);
strcpy(drag_data, "");
}
else
{
drag_data_size = 0L;
drag_data = NULL;
}
for (i=0; i<window->w_hight; i++)
{
if (setin(new_obj, i + (short)window->doc.y))
{
get_prj_line_file(window->link, i + (short)window->doc.y, drag_filename);
if (drag_filename[0] != EOS)
{
if (num_objs > 1)
{
if (drag_data[0] != EOS)
strcat(drag_data, " ");
strcat(drag_data, drag_filename);
}
/* else steht das Arg in drag_filename */
}
}
} /* for */
if (num_objs > 1)
send_avdrag(obj, mk, DRAGDROP_DATA);
else
send_avdrag(obj, mk, DRAGDROP_PATH);
if (drag_data_size > 0)
{
Mfree(drag_data);
drag_data_size = 0;
}
} /* if av_ */
} /* if !my_window */
}
if (mk->breturn==2) /* Doppelklick */
{
unclick_window();
sel_window = window;
setincl(sel_objs,y);
draw_line(window,y);
graf_mkstate (&result, &result, &mobutton, &result);
if (mobutton&1) /* Immernoch gedrückt ? */
evnt_button(1, 1, 0, &result, &result, &result, &result);
do_icon(window->link+SUB_ICON,DO_OPEN);
}
}
/***************************************************************************/
LOCAL VOID wi_unclick (WINDP window)
{
SET help;
WORD i, max;
setcpy(help,sel_objs);
setclr(sel_objs);
max = setmax(help);
for (i=setmin(help); i<=max; i++)
if (setin(help,i))
draw_line(window,i);
set_winfo(window,"");
}
/***************************************************************************/
LOCAL VOID sel_line(WINDP window, WORD line)
{
if (sel_window!=NULL)
unclick_window();
sel_window = window;
setincl(sel_objs,line);
draw_line(window,line);
line -= (short) window->doc.y;
if (line<0)
arrow_window(window,WA_UPLINE,-line);
else
{
line -= (window->w_hight-1);
if (line>0)
arrow_window(window,WA_DNLINE,line);
}
}
LOCAL VOID shift_up(WINDP window)
{
WORD i;
if (window->doc.h == 0)
return;
if (sel_window == window)
{
i = setmin(sel_objs);
if (i == 0)
return ;
i -= window->w_hight;
if (i < 0)
i = 0;
sel_line(window,i);
}
else
sel_line(window, (short)window->doc.h-1);
}
LOCAL VOID shift_down(WINDP window)
{
WORD i;
if (window->doc.h == 0)
return ;
if (sel_window == window)
{
i = setmin(sel_objs);
if (i == window->doc.h - 1)
return ;
i += window->w_hight;
if (i >= window->doc.h)
i = (short) window->doc.h - 1;
sel_line(window,i);
}
else
sel_line(window,0);
}
LOCAL BOOLEAN wi_key (WINDP window, MKINFO *mk)
{
UBYTE asc;
WORD i, key;
BOOLEAN erg;
/* Damit F-Tasten zum System-Desktop kommen! */
if ((mk->scan_code >= 0x3B00 && mk->scan_code <= 0x4400) ||
(mk->scan_code >= 0x5400 && mk->scan_code <= 0x5D00))
return FALSE;
erg = FALSE;
if ((mk->kreturn & NKF_FUNC) && (mk->kreturn & NKF_SHIFT))
{
key = mk->kreturn & ~(NKF_FUNC|NKF_SHIFT);
switch (key)
{
case NK_CLRHOME :
v_slider(window, 1000);
sel_line(window, (short)window->doc.h - 1);
erg = TRUE;
break;
case NK_UP :
shift_up(window);
erg = TRUE;
break;
case NK_DOWN:
shift_down(window);
erg = TRUE;
break;
default:
erg = FALSE;
break;
}
}
else if (mk->kreturn & NKF_FUNC)
{
key = mk->kreturn & ~(NKF_FUNC);
switch (key)
{
case NK_RET :
do_icon(window->link+SUB_ICON, DO_OPEN);
erg = TRUE;
break;
case NK_CLRHOME :
v_slider(window, 0);
sel_line(window,0);
erg = TRUE;
break;
case NK_UP :
if (window->doc.h == 0)
break;
if (sel_window == window)
{
i = setmin(sel_objs);
if (i == 0)
break;
i--;
if (i < 0)
i = 0;
sel_line(window,i);
}
else
sel_line(window, (short)window->doc.h - 1);
erg = TRUE;
break;
case NK_DOWN:
if (window->doc.h == 0)
break;
if (sel_window == window)
{
i = setmin(sel_objs);
if (i==window->doc.h-1)
break;
i++;
if (i >= window->doc.h)
i = (short) window->doc.h-1;
sel_line(window,i);
}
else
sel_line(window,0);
erg = TRUE;
break;
case NK_HELP : /* damit das bei desktop noch ankommt! */
erg = FALSE;
break;
case NK_M_PGUP: /* Mac: page up -> shift-up */
shift_up(window);
erg = TRUE;
break;
case NK_M_PGDOWN: /* Mac: page down -> shift-down */
shift_down(window);
erg = TRUE;
break;
case NK_M_END: /* Mac: end -> shift-home */
v_slider(window, 1000);
sel_line(window, (short)window->doc.h - 1);
erg = TRUE;
break;
default:
if (!(mk->ctrl) && !(mk->alt) && (!mk->shift) && mk->ascii_code)
{
if (sel_window == window)
unclick_window();
else
set_winfo(window,"");
erg = TRUE;
}
else
erg = FALSE;
break;
}
}
else
{
WORD l;
FILENAME name;
PATH str, info;
/* Auto-Locator */
asc = nkc_toupper(mk->ascii_code);
strcpy(info,window->info);
l = (short) strlen(info);
info[l++] = asc;
info[l] = EOS;
i = 0;
do
{
get_prj_line_file(window->link,i,str);
i++;
if (str[0]==EOS)
break;
file_name(str,name, FALSE);
str_upper(name);
}
while (strncmp(name, info, l) != 0);
if (str[0]!=EOS)
{
sel_line(window,i-1);
set_winfo(window,info);
}
erg = TRUE;
}
return erg;
}
/***************************************************************************/
LOCAL VOID wi_snap (WINDP window, RECT *new, WORD mode)
{
WORD w, ex, pxy[8];
/* zunächst Platz für min. 1+Filename+1 im Fenster */
vqt_extent(vdi_handle, "x", pxy);
ex = pxy[2] - pxy[0];
w = new->w;
if (w < 14 * ex)
w = 14 * ex;
/* nun noch Platz für Fenstertitel (1+8+1) */
if (w < sys_wchar * 10)
w = sys_wchar * 10;
new->w = w;
}
LOCAL VOID wi_iconify (WINDOWP window)
{
TEXTP t_ptr = get_text(window->link);
FILENAME short_name;
make_shortpath(t_ptr->filename, short_name, 8);
set_wname(window, short_name);
}
LOCAL VOID wi_uniconify (WINDOWP window)
{
TEXTP t_ptr = get_text(window->link);
FILENAME name;
file_name(t_ptr->filename, name, TRUE);
set_wname(window, name);
}
/***************************************************************************/
/* Kreieren eines Fensters */
/***************************************************************************/
LOCAL VOID crt_prj (WORD icon, WINDP window)
{
FILENAME name;
WORD initw, inith;
TEXTP t_ptr;
t_ptr = get_text(icon);
initw = gl_wchar * 13;
inith = (desk.h / gl_hchar) * gl_hchar - 7 * gl_hchar;
window->flags = FLAGS;
window->doc.w = 13;
window->doc.h = t_ptr->text.lines;
window->changed = (t_ptr->moved!=0);
window->xfac = gl_wchar;
window->yfac = gl_hchar;
window->w_width = initw/gl_wchar;
window->w_hight = inith/gl_hchar;
window->work.x = sys_wchar + 2 * 8;
window->work.y = 60;
window->work.w = initw;
window->work.h = inith;
window->draw = wi_draw;
window->click = wi_click;
window->unclick = wi_unclick;
window->key = wi_key;
window->snap = wi_snap;
window->icon = winicon;
window->iconify = wi_iconify;
window->uniconify = wi_uniconify;
if (t_ptr->namenlos)
strcpy(name, t_ptr->filename);
else
file_name(t_ptr->filename, name, TRUE);
set_wname(window, name);
set_winfo(window,"");
} /* crt_edit */
/***************************************************************************/
/* Öffnen des Objekts */
/***************************************************************************/
LOCAL BOOLEAN open_prj (WORD icon)
{
BOOLEAN ok;
WINDP window = get_window(icon);
if (window->opened || (window->flags & WI_ICONIFIED))
/* Doppelklick auf Icon und Fenster ist schon offen */
{
top_window (window);
ok = TRUE;
}
else
{
ok = open_window (window);
}
return (ok);
} /* open_prj */
/***************************************************************************/
/* Info des Objekts */
/***************************************************************************/
LOCAL LONG len, bytes;
LOCAL WORD anz, i_icon;
LOCAL WORD count(WORD icon, WORD i)
{
PATH name;
anz++;
get_prj_line_file(icon,i,name);
if ((icon=still_loaded(name))>=0)
{
TEXTP t_ptr;
t_ptr = get_text(icon);
bytes += textring_bytes(&t_ptr->text, t_ptr->ending);
len += t_ptr->text.lines;
return 1;
}
else
{
LONG b,l;
WORD antw;
antw = infoload(name,&b,&l);
bytes += b;
len += l;
return (antw==0)?1:0;
}
}
LOCAL BOOLEAN info_projekt (WORD icon)
{
UBYTE str[32], date[11];
TEXTP t_ptr = get_text(icon);
WORD r_anz, i, antw;
SET all;
BOOLEAN quit = FALSE;
DIALINFO dial;
disable_objc(prjinfo, IPRJSCAN, FALSE);
i_icon = icon;
make_shortpath(t_ptr->filename, str, 30);
fill_ptext (prjinfo, PRJNAME, str); /* Name mit Pfad */
if (ist_leer(&t_ptr->text))
r_anz = 0;
else
r_anz = (short) t_ptr->text.lines;
ltoa(r_anz,str,10);
fill_ptext (prjinfo, PRJFILES, str); /* Dateien-Anzahl */
str[0] = EOS;
fill_ptext (prjinfo, PRJLEN , str); /* Länge in Bytes */
fill_ptext (prjinfo, PRJZEILE , str); /* Länge in Zeilen */
if (t_ptr->namenlos)
str[0] = date[0] = EOS;
else
file_time (t_ptr->filename, date, str);
fill_ptext (prjinfo, PRJDATUM, date); /* Datum */
fill_ptext (prjinfo, PRJZEIT, str); /* Uhrzeit */
Arrow_mouse();
open_dial(prjinfo, FALSE, NULL, &dial);
dial_draw(&dial);
do
{
antw = dial_do(&dial, NULL) & 0x7FFF;
switch (antw)
{
case IPRJSCAN:
if (ist_leer(&t_ptr->text))
r_anz = 0;
else
r_anz = (short) t_ptr->text.lines;
anz = 0;
bytes = len = 0;
setclr(all);
for (i=r_anz; (--i)>=0; )
setincl(all,i);
do_for_prj(i_icon, all, count, TRUE);
if (r_anz==anz) /* alle durchlaufen */
ltoa(bytes,str,10);
else
str[0] = EOS;
fill_ptext (prjinfo, PRJLEN , str); /* Länge in Bytes */
draw_Objc(prjinfo, PRJLEN, 1);
if (r_anz==anz)
ltoa(len,str,10);
else
str[0] = EOS;
fill_ptext (prjinfo, PRJZEILE , str); /* Länge in Zeilen */
draw_Objc(prjinfo, PRJZEILE, 1);
if (r_anz==anz) /* alle durchlaufen */
{
disable_objc(prjinfo, IPRJSCAN, TRUE);
draw_Objc(prjinfo, IPRJSCAN, 1);
}
break;
default:
quit = TRUE;
break;
}
select_objc(prjinfo, antw, FALSE);
draw_Objc(prjinfo, antw, 1);
}
while (!quit);
dial_end(&dial);
Last_mouse();
return TRUE;
}
/******************************************************************************/
/* Default-Projekt */
/******************************************************************************/
VOID open_def_prj(VOID)
{
if (def_prj_path[0] != EOS && global_shift) /* altes abmelden */
{
def_prj_path[0] = EOS;
def_icon = -1;
}
else if (def_prj_path[0] != EOS) /* bekanntes öffnen */
load_projekt(def_prj_path, TRUE, -1, -1, NULL);
else
select_def_prj(); /* nix bekannt, also auswählen */
set_def_prj(); /* Menü anpassen */
}
VOID add_to_def(VOID)
{
WINDP w;
w = real_top();
if (w == NULL)
return;
if (w->link != def_icon)
{
TEXTP t_ptr = get_text(w->link);
if (!t_ptr->namenlos)
add_to_projekt(def_icon, t_ptr->filename, TRUE);
}
}
LOCAL VOID select_def_prj(VOID)
{
FSEL fsel = {"", "*.QPJ"};
PATH name = "";
if (select_file(&fsel, name, STRING(DEFPRJ2STR)))
{
strcpy(def_prj_path, name);
load_projekt(def_prj_path, TRUE, -1, -1, NULL);
}
}
VOID set_def_prj(VOID)
{
FILENAME n = "";
if (def_icon == -1 || def_prj_path[0] == EOS)
{
menu_ienable(menu, MTAKEPRJ, FALSE);
menu_icheck(menu, MPROJEKT, FALSE);
}
else
{
menu_ienable(menu, MTAKEPRJ, TRUE);
menu_icheck(menu, MPROJEKT, TRUE);
}
/* Name ins Menü eintragen */
if (def_prj_path[0] != EOS)
file_name(def_prj_path, n, FALSE);
else
strcpy(n, STRING(DEFPRJSTR));
fillup_menu(MPROJEKT, n, 2);
}
/******************************************************************************/
/* Verwaltung der Liste mit der letzten Position */
/* Die Liste wird nur benutzt, wenn aus einem Projekt eine Datei */
/* geladen wird. */
/******************************************************************************/
/* Sucht in der Liste nach einem Eintrag */
LOCAL BOOLEAN get_lastPos (CONST UBYTE *filename, WORD *x, LONG *y)
{
LINEP lauf;
UBYTE *txt, *p;
PATH name;
lauf = FIRST(&lastPos);
if (lauf == NULL)
return FALSE;
while (!IS_LAST(lauf))
{
txt = TEXT(lauf);
strcpy(name, txt);
p = strchr(name, ' ');
*p = EOS;
if (filematch(name, filename))
{
sscanf(txt, "%s %d %ld", name, x, y);
return TRUE;
}
NEXT(lauf);
}
return FALSE;
}
LOCAL VOID insert_lastPos(CONST UBYTE *name, WORD x, LONG y)
{
LINEP col;
UBYTE str[256];
sprintf(str, "%s %d %ld", name, x, y);
col = new_col_w(str, (short)strlen(str));
col_insert(&(lastPos.head), col);
lastPos.lines++;
}
VOID update_lastPos(CONST UBYTE *filename, WORD x, LONG y)
{
LINEP lauf;
UBYTE *txt, *p;
PATH name;
UBYTE str[256];
lauf = FIRST(&lastPos);
if (lauf == NULL)
return ;
while (!IS_LAST(lauf))
{
txt = TEXT(lauf);
strcpy(name, txt);
p = strchr(name, ' ');
*p = EOS;
if (filematch(name, filename))
{
sprintf(str, "%s %d %ld", name, x, y); /* Eintrag aktualisieren */
col_delete(lauf);
lastPos.lines--;
insert_lastPos(filename, x, y);
return;
}
NEXT(lauf);
}
}
/******************************************************************************/
/* Initialisierung */
/******************************************************************************/
VOID init_projekt(VOID)
{
get_path(df_path, 0); /* Aktuellen Pfad holen */
namenlos_anz = 0;
setclr(used_info);
prj_type = decl_icon_type(icon_test,icon_edit,icon_exist,icon_drag);
def_prj_path[0] = EOS;
def_icon = -1;
init_textring(&lastPos);
}
VOID term_project(VOID)
{
/* Führt unte MultiTOS zu Speicherverletzung, warum auch immer */
/* kill_textring(&lastPos); */
}